<template>
    <el-row  type="flex" justify="space-between" align="middle" style="height: 40px; width: 100%">
            <el-col :span="6">{{ treeNode.name }}</el-col>
            <el-col :span="4">
              <el-row type="flex">
                <el-col>{{ treeNode.manager }}</el-col>
                <el-col>
                  <el-dropdown @command="handleCommand">
                    <span class="el-dropdown-link">
                      操作<i class="el-icon-arrow-down el-icon--right"></i>
                    </span>
                    <el-dropdown-menu slot="dropdown">
                      <el-dropdown-item command="add">添加子部门</el-dropdown-item>
                      <el-dropdown-item v-if="!isRoot" command="edit">编辑部门</el-dropdown-item>
                      <el-dropdown-item v-if="!isRoot" command="delete">删除部门</el-dropdown-item>
                    </el-dropdown-menu>
                  </el-dropdown>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
</template>

<script>
export default {
    name:"tree",
    props:{
        treeNode:{
            type:Object,
            required:true,
        },
        isRoot:{
            type:Boolean,
            default:false,
        }
    },
    methods:{
      handleCommand(type){
         
        if(type=='add'){
          console.log(type);
          this.$emit("addDepart",this.treeNode);
        }else if(type=="edit"){
            this.$emit("editDepart",this.treeNode);
        }else{
          // console.log(type,this.treeNode.id);
          this.$emit("deleteDepart",this.treeNode.id);
          
        }
      }
    }
}
</script>

<style>

</style>